

export default {
  mounted(el, binding) {
    let timer = null
    let card = null
    const rowData = binding.value // 获取绑定的行数据
  
    el.addEventListener('mouseenter', () => {
      timer = setTimeout(() => {
        // 创建卡片元素
        card = document.createElement('div')
        card.className = 'custom-hover-card'
        card.innerHTML = `
          <div class="card-header">${rowData.name} 的详情</div>
          <div class="card-body">
            <p>创建时间: ${rowData.createtime}</p>
            <p>更新时间: ${rowData.updatetime}</p>
          </div>
        `
        document.body.appendChild(card)
  
        // 定位卡片（基于当前行位置）
        const rect = el.getBoundingClientRect()
        card.style.position = 'fixed'
        card.style.left = `${rect.left}px`
        card.style.top = `${rect.bottom + window.scrollY}px`
        card.style.zIndex = '9999'
      }, 2000) // 2秒延迟
    })
  
    el.addEventListener('mouseleave', () => {
      clearTimeout(timer)
      if (card) {
        document.body.removeChild(card)
        card = null
      }
    })
  }
}
// app.directive('hover-card', {
// })